﻿<%@ Page Title="Colors Attribute" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ColorsAttribute.aspx.cs" Inherits="ColorApplication.color.ColorsAttribute" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="adminContent">
        <h2>Color Attribute
        </h2>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div id="modalPage" runat="server" class="modalPage">
                    <div class="modalBackground">
                    </div>
                    <div class="modalContainer">
                        <div class="modal">
                            <table>
                                <tr>
                                    <td align="center">
                                        <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                            padding-top: 5px;">
                                            Please Wait...
                                        <br />
                                            <img src="../Images/preloader.gif" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
                <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
                <asp:DetailsView ID="ColorAttributeDetailsView" runat="server" Height="50px" Width="100%"
                    OnItemInserted="ColorAttributeDetailsView_ItemInserted" OnItemUpdated="ColorAttributeDetailsView_ItemUpdated"
                    AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="ColorAttributeDetailsViewSqlDataSource"
                    DefaultMode="Insert" OnItemInserting="ColorAttributeDetailsView_ItemInserting"
                    OnItemUpdating="ColorAttributeDetailsView_ItemUpdating" OnDataBound="ColorAttributeDetailsView_DataBound">
                    <Fields>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:TemplateField HeaderText="Arrtibute" SortExpression="AttributeId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditAttributeDropDownList" runat="server" Text='<%# Bind("AttributeId") %>'
                                    DataSourceID="EditAttributeSqlDataSource" DataTextField="Description" DataValueField="Id">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="EditAttributeSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetAttributesSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="EditAttributeRequiredFieldValidator" runat="server"
                                    ControlToValidate="EditAttributeDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select an attribute."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertAttributeDropDownList" runat="server" Text='<%# Bind("AttributeId") %>'
                                    DataSourceID="InsertAttributeSqlDataSource" DataTextField="Description" DataValueField="Id"
                                    OnDataBound="InsertAttributeDropDownList_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertAttributeSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetAttributesSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertAttributeRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertAttributeDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select an attribute."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("AttributeId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Color" SortExpression="ColorId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditColorDropDownList" runat="server" Text='<%# Bind("ColorId") %>'
                                    DataSourceID="EditColorSqlDataSource" DataTextField="Description" DataValueField="Id"
                                    AutoPostBack="True" OnSelectedIndexChanged="EditColorDropDownList_SelectedIndexChanged">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="EditColorSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetColorsSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="EditColorRequiredFieldValidator1" runat="server"
                                    ControlToValidate="EditColorDropDownList" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="Please select a color."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertColorDropDownList" runat="server" Text='<%# Bind("ColorId") %>'
                                    DataSourceID="InsertColorSqlDataSource" DataTextField="Description" DataValueField="Id"
                                    AutoPostBack="True" OnSelectedIndexChanged="InsertColorDropDownList_SelectedIndexChanged"
                                    OnDataBound="InsertColorDropDownList_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertColorSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetColorsSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertColorRequiredFieldValidator1" runat="server"
                                    ControlToValidate="InsertColorDropDownList" CssClass="failureNotification" Display="Dynamic"
                                    ErrorMessage="Please select a color."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("ColorId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Brightness Level From">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditBrightnessLevelFromDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessLevelFrom") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertBrightnessLevelFromDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessLevelFrom") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertBrightnessLevelFromSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetColorsSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Double" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertBrightnessLevelFromRequiredFieldValidator"
                                    runat="server" ControlToValidate="InsertBrightnessLevelFromDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select a Brightness Level."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="BrightnessLevelFromLabel" runat="server" Text='<%# Bind("BrightnessLevelFrom") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Brightness Level To">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditBrightnessLevelToDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessLevelTo") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertBrightnessLevelToDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessLevelTo") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertBrightnessLevelToSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="GetColorsSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Double" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertBrightnessLevelToRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertBrightnessLevelToDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select a Brightness Level."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="BrightnessLevelToLabel" runat="server" Text='<%# Bind("BrightnessLevelTo") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Brightness Max Value">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditBrightnessMaxValueDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessMaxValue") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertBrightnessMaxValueDropDownList" runat="server" SelectedValue='<%# Bind("BrightnessMaxValue") %>'>
                                    <asp:ListItem Value="0.00">0</asp:ListItem>
                                    <asp:ListItem Value="0.50">0.5</asp:ListItem>
                                    <asp:ListItem Value="1.00">1</asp:ListItem>
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="BrightnessMaxValueLabel" runat="server" Text='<%# Bind("BrightnessMaxValue") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Dominant" SortExpression="IsDominant">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditDominantDropDownList" runat="server" SelectedValue='<%# Bind("IsDominant") %>'>
                                    <asp:ListItem>True</asp:ListItem>
                                    <asp:ListItem>False</asp:ListItem>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertDominantDropDownList" runat="server" SelectedValue='<%# Bind("IsDominant") %>'>
                                    <asp:ListItem>True</asp:ListItem>
                                    <asp:ListItem>False</asp:ListItem>
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("IsDominant") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Show Color">
                            <EditItemTemplate>
                                <asp:TextBox ID="EditShowColorTextBox" Height="20px" Width="20px" BorderStyle="None"
                                    Enabled="false" runat="server" ReadOnly="true"></asp:TextBox>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="InsertShowColorTextBox" Height="20px" Width="20px" BorderStyle="None"
                                    Enabled="false" runat="server" ReadOnly="true"></asp:TextBox>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:TextBox ID="ItemShowColorTextBox" runat="server" ReadOnly="true"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="ColorAttributeDetailsViewSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" InsertCommand="InsertColorsAttributeInsert"
                    InsertCommandType="StoredProcedure" SelectCommand="GetSearchByColorsAttributeSelect"
                    SelectCommandType="StoredProcedure" UpdateCommand="UpdateColorsAttributeUpdate"
                    UpdateCommandType="StoredProcedure">
                    <InsertParameters>
                        <asp:Parameter Name="ColorId" Type="Int32" />
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                        <asp:Parameter Name="BrightnessLevelFrom" Type="Double" />
                        <asp:Parameter Name="BrightnessLevelTo" Type="Double" />
                        <asp:Parameter Name="BrightnessMaxValue" Type="Double" />
                        <asp:Parameter Name="IsDominant" Type="Boolean" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ColorAttributeGridView" Name="Id" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="ColorId" Type="Int32" />
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                        <asp:Parameter Name="BrightnessLevelFrom" Type="Double" />
                        <asp:Parameter Name="BrightnessLevelTo" Type="Double" />
                        <asp:Parameter Name="BrightnessMaxValue" Type="Double" />
                        <asp:Parameter Name="IsDominant" Type="Boolean" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                <br />
                <asp:GridView ID="ColorAttributeGridView" runat="server" AutoGenerateColumns="False"
                    DataKeyNames="Id" DataSourceID="ColorAttributegridSqlDataSource" OnRowDataBound="ColorAttributeGridView_RowDataBound"
                    OnSelectedIndexChanged="ColorAttributeGridView_SelectedIndexChanged" Width="80%"
                    AllowSorting="True">
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="Color" HeaderText="Color" SortExpression="Color" />
                        <asp:BoundField DataField="Attribute" HeaderText="Attribute" SortExpression="Attribute" />
                        <asp:BoundField DataField="BrightnessLevelFrom" HeaderText="BrightnessLevelFrom"
                            SortExpression="BrightnessLevelFrom" />
                        <asp:BoundField DataField="BrightnessLevelTo" HeaderText="BrightnessLevelTo" SortExpression="BrightnessLevelTo" />
                        <asp:BoundField DataField="BrightnessMaxValue" HeaderText="BrightnessMaxValue" SortExpression="BrightnessMaxValue" />
                        <asp:BoundField DataField="IsDominant" HeaderText="IsDominant" SortExpression="IsDominant" />
                        <asp:TemplateField HeaderText="Show Color">
                            <ItemTemplate>
                                <asp:TextBox ID="ShowColorTextBox" Height="20px" Width="20px" BorderStyle="None"
                                    Enabled="false" ReadOnly="true" runat="server"></asp:TextBox>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="ColorAttributegridSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" DeleteCommand="DeleteColorsAttributeDelete"
                    DeleteCommandType="StoredProcedure" SelectCommand="GetSearchByColorsAttributeSelect"
                    SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="ColorId" Type="Int32" />
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                        <asp:Parameter Name="BrightnessLevelFrom" Type="Double" />
                        <asp:Parameter Name="BrightnessLevelTo" Type="Double" />
                        <asp:Parameter Name="BrightnessMaxValue" Type="Double" />
                        <asp:Parameter Name="IsDominant" Type="Boolean" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
